AmCharts.AmPieChart=AmCharts.Class({inherits:AmCharts.AmSlicedChart,construct:function(t){this.type="pie";AmCharts.AmPieChart.base.construct.call(this,t);this.cname="AmPieChart";this.pieBrightnessStep=30;this.minRadius=10;this.depth3D=0;this.startAngle=90;this.angle=this.innerRadius=0;this.startRadius="500%";this.pullOutRadius="20%";this.labelRadius=20;this.labelText="[[title]]: [[percents]]%";this.balloonText="[[title]]: [[percents]]% ([[value]])\n[[description]]";this.previousScale=1;AmCharts.applyTheme(this,t,this.cname)},drawChart:function(){AmCharts.AmPieChart.base.drawChart.call(this);var t=this.chartData;if(AmCharts.ifArray(t)){if(0<this.realWidth&&0<this.realHeight){AmCharts.VML&&(this.startAlpha=1);var i=this.startDuration,e=this.container,a=this.updateWidth();this.realWidth=a;var s=this.updateHeight();this.realHeight=s;var h=AmCharts.toCoordinate,r=h(this.marginLeft,a),l=h(this.marginRight,a),n=h(this.marginTop,s)+this.getTitleHeight(),d=h(this.marginBottom,s),o,p,c,u=AmCharts.toNumber(this.labelRadius),g=this.measureMaxLabel();g>this.maxLabelWidth&&(g=this.maxLabelWidth);this.labelText&&this.labelsEnabled||(u=g=0);o=void 0===this.pieX?(a-r-l)/2+r:h(this.pieX,this.realWidth);p=void 0===this.pieY?(s-n-d)/2+n:h(this.pieY,s);c=h(this.radius,a,s);c||(a=0<=u?a-r-l-2*g:a-r-l,s=s-n-d,c=Math.min(a,s),s<a&&(c/=1-this.angle/90,c>a&&(c=a)),s=AmCharts.toCoordinate(this.pullOutRadius,c),c=(0<=u?c-1.8*(u+s):c-1.8*s)/2);c<this.minRadius&&(c=this.minRadius);s=h(this.pullOutRadius,c);n=AmCharts.toCoordinate(this.startRadius,c);h=h(this.innerRadius,c);h>=c&&(h=c-1);d=AmCharts.fitToBounds(this.startAngle,0,360);0<this.depth3D&&(d=270<=d?270:90);d-=90;a=c-c*this.angle/90;for(r=0;r<t.length;r++)if(l=t[r],!0!==l.hidden&&0<l.percents){var m=360*l.percents/100,g=Math.sin((d+m/2)/180*Math.PI),C=-Math.cos((d+m/2)/180*Math.PI)*(a/c),b=this.outlineColor;b||(b=l.color);var A=this.alpha;isNaN(l.alpha)||(A=l.alpha);b={fill:l.color,stroke:b,"stroke-width":this.outlineThickness,"stroke-opacity":this.outlineAlpha,"fill-opacity":A};l.url&&(b.cursor="pointer");b=AmCharts.wedge(e,o,p,d,m,c,a,h,this.depth3D,b,this.gradientRatio,l.pattern);AmCharts.setCN(this,b,"pie-item");AmCharts.setCN(this,b.wedge,"pie-slice");AmCharts.setCN(this,b,l.className,!0);this.addEventListeners(b,l);l.startAngle=d;t[r].wedge=b;0<i&&(this.chartCreated||b.setAttr("opacity",this.startAlpha));l.ix=g;l.iy=C;l.wedge=b;l.index=r;if(this.labelsEnabled&&this.labelText&&l.percents>=this.hideLabelsPercent){var v=d+m/2;360<v&&(v-=360);var f=u;isNaN(l.labelRadius)||(f=l.labelRadius);var m=o+g*(c+f),A=p+C*(c+f),R,x=0;if(0<=f){var y;90>=v&&0<=v?(y=0,R="start",x=8):90<=v&&180>v?(y=1,R="start",x=8):180<=v&&270>v?(y=2,R="end",x=-8):270<=v&&360>v&&(y=3,R="end",x=-8);l.labelQuarter=y}else R="middle";var v=this.formatString(this.labelText,l),k=this.labelFunction;k&&(v=k(l,v));k=l.labelColor;k||(k=this.color);""!=v&&(v=AmCharts.wrappedText(e,v,k,this.fontFamily,this.fontSize,R,!1,this.maxLabelWidth),AmCharts.setCN(this,v,"pie-label"),AmCharts.setCN(this,v,l.className,!0),v.translate(m+1.5*x,A),v.node.style.pointerEvents="none",l.tx=m+1.5*x,l.ty=A,0<=f?(f=v.getBBox(),k=AmCharts.rect(e,f.width+5,f.height+5,"#FFFFFF",.005),k.translate(m+1.5*x+f.x,A+f.y),l.hitRect=k,b.push(v),b.push(k)):this.freeLabelsSet.push(v),l.label=v);l.tx=m;l.tx2=m+x;l.tx0=o+g*c;l.ty0=p+C*c}m=h+(c-h)/2;l.pulled&&(m+=this.pullOutRadiusReal);l.balloonX=g*m+o;l.balloonY=C*m+p;l.startX=Math.round(g*n);l.startY=Math.round(C*n);l.pullX=Math.round(g*s);l.pullY=Math.round(C*s);this.graphsSet.push(b);(0===l.alpha||0<i&&!this.chartCreated)&&b.hide();d+=360*l.percents/100}0<u&&!this.labelRadiusField&&this.arrangeLabels();this.pieXReal=o;this.pieYReal=p;this.radiusReal=c;this.innerRadiusReal=h;0<u&&this.drawTicks();this.initialStart();this.setDepths()}(t=this.legend)&&t.invalidateSize()}else this.cleanChart();this.dispDUpd();this.chartCreated=!0},setDepths:function(){var t=this.chartData,i;for(i=0;i<t.length;i++){var e=t[i],a=e.wedge,e=e.startAngle;0<=e&&180>e?a.toFront():180<=e&&a.toBack()}},arrangeLabels:function(){var t=this.chartData,i=t.length,e,a;for(a=i-1;0<=a;a--)e=t[a],0!==e.labelQuarter||e.hidden||this.checkOverlapping(a,e,0,!0,0);for(a=0;a<i;a++)e=t[a],1!=e.labelQuarter||e.hidden||this.checkOverlapping(a,e,1,!1,0);for(a=i-1;0<=a;a--)e=t[a],2!=e.labelQuarter||e.hidden||this.checkOverlapping(a,e,2,!0,0);for(a=0;a<i;a++)e=t[a],3!=e.labelQuarter||e.hidden||this.checkOverlapping(a,e,3,!1,0)},checkOverlapping:function(t,i,e,a,s){var h,r,l=this.chartData,n=l.length,d=i.label;if(d){if(!0===a)for(r=t+1;r<n;r++)l[r].labelQuarter==e&&(h=this.checkOverlappingReal(i,l[r],e))&&(r=n);else for(r=t-1;0<=r;r--)l[r].labelQuarter==e&&(h=this.checkOverlappingReal(i,l[r],e))&&(r=0);!0===h&&100>s&&(h=i.ty+3*i.iy,i.ty=h,d.translate(i.tx2,h),i.hitRect&&(d=d.getBBox(),i.hitRect.translate(i.tx2+d.x,h+d.y)),this.checkOverlapping(t,i,e,a,s+1))}},checkOverlappingReal:function(t,i,e){var a=!1,s=t.label,h=i.label;t.labelQuarter!=e||t.hidden||i.hidden||!h||(s=s.getBBox(),e={},e.width=s.width,e.height=s.height,e.y=t.ty,e.x=t.tx,t=h.getBBox(),h={},h.width=t.width,h.height=t.height,h.y=i.ty,h.x=i.tx,AmCharts.hitTest(e,h)&&(a=!0));return a}});
//# sourceMappingURL=pie.map.js